<template>
  <div class="search-artist">
    <div class="item"
         v-for="(item,index) in artist"
         :key="index"
         @click="enterArtist(index)">
      <div class="left">
        <img :src="item.picUrl"
             alt="">
      </div>
      <div class="right">
        <p class="name">{{item.name}}</p>
        <p class="album">专辑数：{{item.albumSize}}</p>
        <p class="mv">mv数：{{item.mvSize}}</p>
      </div>
    </div>
  </div>
</template>

<script>
import { _Search } from 'network/search'
export default {
  name: 'SearchArtist',
  data () {
    return {
      // 搜索类型
      searchType: 100,
      artist: [],
      keywords: ''
    };
  },
  created () {
    this.Search();
  },
  methods: {
    Search () {
      // 获取活跃路由参数
      this.keywords = this.$route.params.key;
      _Search(this.keywords, this.searchType).then(res => {
        this.artist = res.data.result.artists;
      })
    },
    enterArtist (index) {
      this.$router.push('/artist/' + this.artist[index].id)
    }
  }
}
</script>

<style scoped>
.search-artist {
  width: 100%;
  height: 100%;
  font-size: 12px;
  color: #333;
}
.search-artist .item {
  width: 100%;
  height: 60px;
  display: flex;
}
.item .left {
  width: 5%;
}
.item img {
  width: 40px;
  height: 40px;
  border-radius: 10px;
}
.right {
  flex: 1;
}
</style>
